#include <stdio.h>
#include <stdlib.h>

//自定义类型  结构体

struct student
{
    int num;
    char *name;
    char sex;
    float score;
} stu3, stu4 = {102, "张三", 'M', 90.5}; //也可以在定义结构体的时候申明结构体变量,这里只为stu4变量初始化了

//直接说明结果提变量
struct
{
    int num;
    char name[20];
    char sex;
    float score;
} per1, per2;

int main()
{
    printf("\n\n========================================================================\n\n");
    //结构体变量的说明
    struct student stu1, stu2;
    //结构体变量赋初值

    stu1.num = 10;
    stu1.name = "sss";

    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu1.num, stu1.name, stu1.sex, stu1.score);
    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu4.num, stu4.name, stu4.sex, stu4.score);
    stu2=stu4;//把stu4的成员变量全部赋值给stu2，这里是深拷贝，并不意味着stu2只是对stu4的引用
    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu2.num, stu2.name, stu2.sex, stu2.score);
    stu2.name="李四";//改变stu2成员变量不会影响stu4
    printf("stu1:num=%d,name=%s,sex=%c,score=%f\n", stu2.num, stu2.name, stu2.sex, stu2.score);




    printf("\n\n========================================================================\n\n");
    return 0;
}